<template>
  <div class="wg-cap-wrap" :style="{width: width}">
    <div class="wg-cap-wrap__header">
      <span>验证码：</span>
    </div>

    <div class="wg-cap-wrap__body">
      <img class="wg-cap-wrap__picture" v-if="imageUrl" :src="imageUrl" alt=" " @click="$emit('handleRefresh')">
      <img class="wg-cap-wrap__loading"
           src=""
           alt="正在加载中...">
    </div>

    <div class="wg-cap-wrap__footer">
      <div class="wg-cap-wrap__ico">
        <el-input v-model="input" style="width: 240px" placeholder="请输入上图的验证码" />
      </div>
      <div class="wg-cap-wrap__btn">
        <el-button type="primary" @click="$emit('handleConfirm', input)">确认</el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const input = ref('')

defineProps({
  imageUrl: String,
  width: {
    type: String,
    default: '300px'
  }
})
</script>

<style scoped lang="stylus">
.wg-cap-wrap {
  background: #ffffff;

  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;

  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;

  .wg-cap-wrap__header {
    height: 50px;
    width: 100%;
    font-size: 15px;

    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    justify-content: aaa;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;

  }

  .wg-cap-wrap__body {
    position: relative;
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    background: #34383e;
    margin: auto;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    overflow: hidden;
    width: 100%;
    height: 90px;

    .wg-cap-wrap__picture {
      position: relative;
      z-index: 10;
      width: 100%;
    }

    .wg-cap-wrap__loading {
      position: absolute;
      z-index: 9;
      top: 50%;
      left: 50%;
      width: 68px;
      height: 68px;
      margin-left: -34px;
      margin-top: -34px;
      line-height: 68px;
      text-align: center;
    }
  }

  .wg-cap-wrap__footer {
    width: 100%;
    height: 40px;
    color: #34383e;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    padding-top: 15px;

    .wg-cap-wrap__ico {
      flex: 1;

      img {
        width: 24px;
        height: 24px;
        color: #34383e;
        margin: 0 5px;
        cursor: pointer;
      }
    }

    .wg-cap-wrap__btn {
      display flex
      width: 120px;
      justify-content right
    }
  }
}
</style>